<?php
/*
  $Id: products_new.php,v 1.27 2003/06/09 22:35:33 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCTS_NEW);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCTS_NEW));
  
  require(DIR_WS_INCLUDES . 'template_top.php');
?>
<div class="middle-area">
  <div class="innermidbox fl">
    <div class="innermidbox-top"></div>
    <div class="innermidbox-mid">
      <div class="pdt5 pdl20 pdr20 pdb5 minheight527px">
        <div class="breadcrumbs"><a href="index.php">Home</a> > <span><?php echo HEADING_TITLE; ?></span></div>
        <div class="spacer10"></div>
        <div class="">
          <h1 class="pagetitle"><?php echo HEADING_TITLE; ?></h1>
          <div class="hline"></div>
          <div class="spacer3"></div>
          <!--left panel start-->
          <?php include('includes/template_left.php'); ?>
          <!--left panel end-->
          <!--right panel start-->
          <div class="rightpanel mgl15 fl">
            <!--listing start-->
            <?php
  $products_new_array = array();

  $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, DATE_FORMAT(p.products_date_added,'%d %M %Y') as products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name";
  $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

  if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
            <div class="pagingbox">
              <div class="pdl10 pdt5 pdb5 pdr10">
                <div class="fl"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></div>
                <div class="fr">
                  <div class="paging "> <?php echo $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?> </div>
                </div>
                <div class="clear"></div>
              </div>
            </div>
            <!--paging end-->
            <div class="spacer10"></div>
            <?php
  }
?>
            <?php
  if ($products_new_split->number_of_rows > 0) {
	  $rows = 0;
    $products_new_query = tep_db_query($products_new_split->sql_query);
    while ($products_new = tep_db_fetch_array($products_new_query))
	{
		$rows++;
		
      if ($new_price = tep_get_products_special_price($products_new['products_id'])) {
		
        //CGDiscountSpecials start
		//if ($product_info['products_price'] < $new_price)
        //  $products_new['products_price'] = $new_price + $new_price * 5 / 100; //add 5% to price if original price is greater than special prices, customers will be happy :)
        $products_price = '<s>' . $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price_nodiscount($new_price, tep_get_tax_rate($products_new['products_tax_class_id'])) . '</span>';
        //CGDiscountSpecials end

      } else {
        $products_price = $currencies->display_price($products_new['products_price'], tep_get_tax_rate($products_new['products_tax_class_id']));
      }
	  
	  if(($rows+2)%3==0)
	  {
		?>
            <div class="productmainbox fl">
		<?php
	  }
		else	
		{
	?>
              <div class="productmainbox fl mgl14">
		<?php
		}
    	?>
                <div class="pdl5 pdr5 pdt5 pdb5">
                  <div class="productimgbg mgl1"> <a href="<?=tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id'])?>" title="<?=$products_new['products_name']?>" >
                    <?=tep_image(DIR_WS_IMAGES . $products_new['products_image'], $products_new['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT)?>
                    </a> </div>
                  <div class="spacer5"></div>
                  <div class="pdl5 pdr5">
                    <h3 class="listproductname"><a href="<?=tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id'])?>" title="<?=$products_new['products_name']?>" >
                      <?=$products_new['products_name']?>
                      </a></h3>
                    <div class="spacer3"></div>
                    <span class="listdesc">
                    <?=TEXT_MANUFACTURER?>
                    <?=$products_new['manufacturers_name']?>
                    </span>
                    <div class="spacer5"></div>
                    <span class="listdesc">
                    <?=TEXT_DATE_ADDED?>
                    <?=$products_new['products_date_added']?>
                    </span>
                    <div class="spacer5"></div>
                    <a class="readmorered fl" href="<?=tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new['products_id'])?>" title="<?=$products_new['products_name']?>">Read More</a>
                    <div class="fr listproductprice">
                      <?=$products_price;?>
                    </div>
                    <div class="spacer5"></div>
                    <a class="listaddtocartbtn" href="<?=tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new['products_id'])?>"></a> </div>
                </div>
              </div>
              <?php
			
            if($rows%3==0)
			{
            ?>
              <div class="spacer14"></div>
              <?php
            }

    }
  } else {
?>
              <?php echo TEXT_NO_NEW_PRODUCTS; ?>
              <?php
  }
?>
              <?php
  if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
              <div class="spacer10"></div>
              <div class="pagingbox">
                <div class="pdl10 pdt5 pdb5 pdr10">
                  <div class="fl"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></div>
                  <div class="fr">
                    <div class="paging "> <?php echo $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?> </div>
                  </div>
                  <div class="clear"></div>
                </div>
              </div>
              <!--paging end-->
              <?php
  }
?>
              <!--listing end-->
            </div>
            <!--right panel end-->
            <div class="spacer10"></div>
          </div>
        </div>
      </div>
      <div class="innermidbox-bottom"></div>
    </div>
  </div>
  <!--middle area end-->
  <div class="spacer25"></div>
</div>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>